<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
class News extends Controller
{
	function __construct(){
		parent::__construct();
		$this->news = db('news');
	}
	
	/*
	*	新闻列表
	*/
    public function news()
    {
    	$type = input('type');
		$list = $this->news->where("type='$type'")->select();
		for ($i=0; $i < count($list); $i++) { 
			$list[$i]['images'] = IMG_PATH.$list[$i]['images'];
		}
		$news = db('news_type')->field("id,name")->select();
		$this->assign("news",$news);
		
		$this->assign("list",$list);
		$this->assign("type",$type);
		return $this->fetch();
    }
	/*
	*	新闻详情
	*/
	public function details()
	{
		$id   = input('id');
		$detail = $this->news->where("id='$id'")->find();
		$detail['images'] = IMG_PATH.$detail['images'];
		$type = $detail['type'];
		$news = db('news_type')->field("id,name")->select();
		$this->assign("news",$news);
		$this -> assign("data",$detail);
		$this->assign("type",$type);
		return $this->fetch();
	}
	
	
   
	
}